﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Configuration;
using System.Configuration;

public partial class Contact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Refresh();
        }
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        SmtpSection cfg = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");
        string checkError=SendEmailProviders.CheckError(SendEmailProviders.RoleSendEmail.User,
                "Chào Admin EM07 Business",
                txtFullName.Text,
                txtEmailFrom.Text,
                cfg.From,
                txtEmailSubject.Text,
                CKEditoConent.Text).ToString();
        if (checkError == "" && recaptcha.IsValid)
        {

           string msg = SendEmailProviders.Send(SendEmailProviders.RoleSendEmail.User,
                "Chào Admin EM07 Business",
                txtFullName.Text,
                txtEmailFrom.Text,
                cfg.From,
                txtEmailSubject.Text,
                CKEditoConent.Text,
                Server.MapPath("MailContactClient.htm")).ToString();
           NotificationMessage.InnerHtml = NotificationHelper.SetNotification(NotificationHelper.Notification.success, msg);
        }
        else
        {
            NotificationMessage.InnerHtml = NotificationHelper.SetNotification(NotificationHelper.Notification.error,string.Format("{0}<br/>{1}", checkError, "Mã bảo vệ không trùng khớp.Vui lòng nhập lại"));
        }
    }

    protected void btnClear_Click(object sender, EventArgs e)
    {
        Refresh();
    }

    protected void Refresh()
    {
        txtEmailSubject.Text = "";
        txtFullName.Text = "";
        txtEmailFrom.Text = "";
        CKEditoConent.Text = "";
        NotificationMessage.InnerHtml = "";
    }
    protected void btnClear_Click1(object sender, EventArgs e)
    {
        Refresh();
    }
}